package com.pmcc.core.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by syk on 17/6/23.
 */
@Data
@MappedSuperclass
@JsonInclude(JsonInclude.Include.NON_NULL)
@EntityListeners(AuditingEntityListener.class)
public abstract class BaseEntity {

    @Id
    @GenericGenerator(name = "systemUUID", strategy = "uuid")
    @GeneratedValue(generator = "systemUUID")
    @Column(name = "ID", length = 32)
    private String id;

    @Column(name = "CREATE_ID", length = 32)
    private String createId;//创建人

    @Column(name = "CREATE_NAME", length = 50)
    private String createName;//创建人名称

    @CreatedDate
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(name = "CREATE_TIME")
    private Date createTime;//创建时间

    @Column(name = "MODIFY_ID", length = 32)
    private String modifyId;//修改人

    @Column(name = "MODIFY_NAME", length = 50)
    private String modifyName;//修改人名称

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @LastModifiedDate
    @Column(name = "MODIFY_TIME")
    private Date modifyTime;//修改时间

    @Column(name = "REMARK")
    private String remark;//备注信息

    @Column(name = "DEL_FLAG", length = 10)
    private String delFlag="0";//删除标记

}
